//是否是纯中文
function isChinese(chin) {
  let re = /[^\u4e00-\u9fa5]/
  return !re.test(chin)
}

//检查是否是数字
function isNumber(num) {
  let reg = /^[0-9]+.?[0-9]*$/
  return reg.test(num)
}

//检查手机号格式是否正常
function isMobile(mobile) {
  //正则
  let reg = /^[1][0-9]{10}$/
  return reg.test(mobile)
}

//检查密码格式
function isPass(password) {
  return (password.length > 5 && password.length < 19 && password.match(/\d/) && password.match(/[a-zA-Z]/))
}

//检查邮箱格式
function isEmail(email) {
  let reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/
  return reg.test(email)
}


//检查身份证
function isAllCode(code) {
  var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  return reg.test(code)
}

//检查值是否为空
function isEmpty(v) {
  if ((typeof v == 'string') && v.trim() == '') {
    return true
  }
  if (v == undefined || v == null) {
    return true
  }
  if (Array.isArray(v) && v.length == 0) {
    return true
  }
  if ((typeof v == 'object') && Object.keys(v).length == 0) {
    return true
  }
  if (!!!v) {
    return true
  }
  return false
}

function isbarnd(barnd) {
  var pattern = /^([1-9]{1})(\d{14}|\d{18})$/
  return pattern.test(barnd)
}
// if (!that.check.isMobile(mk_tel)) {
//   return that.toast('手机号不正确！');
// }

export default {
  isMobile,
  isPass,
  isEmail,
  isNumber,
  isEmpty,
  isChinese,
  isAllCode,
  isbarnd,
}
